/* GUI CONVERTED from sqqomtf8.p (converter v1.76) Thu Dec 26 21:32:26 2002 */
/* sqqomtf8.p  - QUOTE MAINTENANCE - CONFIGURED ITEM                          */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.10.1.7 $                                                      */
/*V8:ConvertMode=Maintenance                                                  */
/* REVISION: 7.4      LAST MODIFIED: 10/24/94   BY: ljm *GN62*                */
/* REVISION: 7.4      LAST MODIFIED: 11/04/94   BY: afs *FT39*                */
/* REVISION: 7.3      LAST MODIFIED: 11/11/94   BY: qzl *FT43*                */
/* REVISION: 7.4      LAST MODIFIED: 03/13/95   BY: JPM *H0BZ*                */
/* REVISION: 8.5      LAST MODIFIED: 03/23/94   BY: jlf *J042*                */
/* REVISION: 8.5      LAST MODIFIED: 08/07/95   BY: DAH *J067*                */
/* REVISION: 8.5      LAST MODIFIED: 05/22/96   BY: DAH *J0N2*                */
/* REVISION: 8.5      LAST MODIFIED: 07/08/96   BY: DAH *J0XR*                */
/* REVISION: 8.5      LAST MODIFIED: 07/15/96   BY: ajw *J0Z6*                */
/* REVISION: 8.5      LAST MODIFIED: 07/24/96   BY: *J116* Dennis Henson      */
/* REVISION: 8.5      LAST MODIFIED: 07/29/96   BY: *J12Q* Andy Wasilczuk     */
/* REVISION: 8.5      LAST MODIFIED: 08/12/96   BY: *F0X9* Tony Patel         */
/* REVISION: 8.5      LAST MODIFIED: 09/26/96   BY: *G2G8* Aruna P.Patil      */
/* REVISION: 8.6      LAST MODIFIED: 10/11/95   BY: flm *K003*                */
/* REVISION: 8.6      LAST MODIFIED: 07/30/97   BY: Joe Gawel    *K0H6*       */
/* REVISION: 8.6      LAST MODIFIED: 10/28/97   BY: *K15N* Jerry Zhou         */
/* REVISION: 8.6      LAST MODIFIED: 12/08/97   by: *K1BP* Val Portugal       */
/* REVISION: 8.6      LAST MODIFIED: 01/13/98   by: *K1BP* Murali Ayyagari    */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane          */
/* REVISION: 8.6E     LAST MODIFIED: 05/09/98   BY: *L00Y* Jeff Wootton       */
/* REVISION: 8.6E     LAST MODIFIED: 06/11/98   BY: *L01S* Russ Witt          */
/* REVISION: 8.6E     LAST MODIFIED: 01/11/99   BY: *J388* Surekha Joshi      */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane   */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KN* Mark Brown         */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* Revision: 1.10.1.6      BY: Jean Miller       DATE: 05/13/02  ECO: *P05M*  */
/* $Revision: 1.10.1.7 $            BY: Nishit V          DATE: 12/23/02  ECO: *N22D*  */
/* $Revision: eb2 sp3 $   BY: Joy Huang       DATE: 11/03/03  ECO: *HK-S-015*    */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

{mfdeclre.i}
{gplabel.i} /* EXTERNAL LABEL INCLUDE */

define new shared variable cpex_prefix          as character.
define new shared variable cpex_ordernbr        as character.
define new shared variable cpex_orderline       as integer.
define new shared variable cpex_rev_date        as date.
define new shared variable cpex_order_due_date  as date.
define new shared variable cpex_site            as character.
define new shared variable cpex_ex_rate         like qo_ex_rate.
define new shared variable cpex_ex_rate2        like qo_ex_rate2.
define new shared variable cpex_mfg_lead        like ptp_mfg_lead.
define new shared variable cpex_last_id         as integer.
define new shared variable rfact                as integer.
define new shared variable config_changed       like mfc_logical initial no.
define new shared variable cf_um                like sod_um.
define new shared variable cf_um_conv           like sod_um_conv.

define shared variable qod_recno            as recid.
define shared variable new_line             like mfc_logical.
define shared variable prev_qty_ord         like qod_qty_quot.
define shared variable sngl_ln              like qoc_ln_fmt.
define shared variable line                 like qod_line.
define shared variable clines               as integer.
define shared variable desc1                like pt_desc1.
define shared variable mult_slspsn          like mfc_logical no-undo.
define shared variable qodcmmts             like qoc_lcmmts.
define shared variable lineffdate           like qo_due_date.
define shared variable undo_all2            like mfc_logical.
define shared variable picust               like cm_addr.
define shared variable pics_type            like pi_cs_type.
define shared variable part_type            like pi_part_type.
define shared variable discount             as decimal.
define shared variable line_pricing         like mfc_logical.
define shared variable reprice_dtl          like mfc_logical.
define shared variable new_order            like mfc_logical.
define shared variable qoc_pt_req           like mfc_logical.
define shared variable cf_config            like mfc_logical.
define shared variable cf_error_bom         like mfc_logical.
define shared variable cf_rm_old_bom        like mfc_logical.


define shared frame c.
define shared frame d.
define shared frame bom.

define variable cpex_sod_part    like sod_part.
define variable config_edited    like mfc_logical.
define variable old_price        like qod_price.
define variable old_list_pr      like qod_list_pr.
define variable old_disc         like qod_disc_pct.
define variable modify_sob       like mfc_logical initial no label "Review Bill".
define variable yn               like mfc_logical.
define variable pcqty            like qod_qty_quot.
define variable match_pt_um      like mfc_logical.
define variable minprice         like pc_min_price.
define variable maxprice         like pc_min_price.
define variable pc_recno         as recid.
define variable warning          like mfc_logical initial no.
define variable warmess          like mfc_logical initial yes.
define variable minmaxerr        like mfc_logical.
define variable prev_qty_req     like sob_qty_req.
define variable sobparent        like sob_parent.
define variable sobfeature       like sob_feature.
define variable sobpart          like sob_part.
define variable update_accum_qty like mfc_logical.
define variable err_flag         as integer.
define variable disc_pct_err     as decimal.
define variable disc_min_max     like mfc_logical.

define variable cfg      like qod_cfg_type format "x(3)" no-undo.
define variable cfglabel as   character format "x(24)"label "" no-undo.
define variable cfgcode  as   character format "x(1)" no-undo.
define variable valid_mnemonic like mfc_logical no-undo.
define variable valid_lngd     like mfc_logical no-undo.

if can-find(first lngd_det where
   lngd_lang = global_user_lang and
   lngd_dataset = "pt_mstr" and
   lngd_field   = "pt_cfg_type")
then
   valid_lngd = yes.
else
   valid_lngd = no.

{pppivar.i }  /*SHARED VARIABLES FOR PRICING ROUTINE*/
{pppiwkpi.i } /*PRICING WORKFILE DEFINITIONS*/
{pppiwqty.i } /*ACCUM QTY WORKFILES DEFINITIONS*/

/*HK-S-015          {sqlinfrm.i} /* Define shared forms for line detail */*/
/*HK-S-015*/        {xxsqlinfrm.i}

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
modify_sob  colon 17
   qod_qob_rev colon 17 label "Effective"
 SKIP(.4)  /*GUI*/
with frame bom1 overlay attr-space
side-labels row 9 column 25 NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-bom1-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame bom1 = F-bom1-title.
 RECT-FRAME-LABEL:HIDDEN in frame bom1 = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame bom1 =
  FRAME bom1:HEIGHT-PIXELS - RECT-FRAME:Y in frame bom1 - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME bom1 = FRAME bom1:WIDTH-CHARS - .5.  /*GUI*/


/* SET EXTERNAL LABELS */
setFrameLabels(frame bom1:handle).

find first pic_ctrl no-lock.

if pic_qo_fact then
   rfact = pic_qo_rfact.
else
   rfact = pic_qo_rfact + 2.

find qod_det where recid(qod_det) = qod_recno exclusive-lock.
find qo_mstr where qo_nbr = qod_nbr no-lock.

assign
   cpex_prefix = "qod_det"
   cpex_ordernbr = qod_nbr
   cpex_orderline = qod_line
   cpex_rev_date = qod_qob_rev
   cpex_order_due_date = qod_due_date
   cpex_site = qod_site
   cpex_ex_rate = qo_ex_rate
   cpex_ex_rate2 = qo_ex_rate2
   cpex_mfg_lead = 0
   cpex_sod_part = qod_part
   cpex_last_id = 0.

/* GET LAST SOB_DET RECORD IDENTIFIER */
{gprun.i ""sosomtf7.p""}
/*GUI*/ if global-beam-me-up then undo, leave.


find pt_mstr where pt_part = qod_part no-lock no-error.
if available pt_mstr then
   cpex_mfg_lead = pt_mfg_lead.

find ptp_det where ptp_part = qod_part and ptp_site = qod_site
no-lock no-error.
if available ptp_det then
   cpex_mfg_lead = ptp_mfg_lead.

/* If parameter is yes, then update "accum qty" workfiles
   before processing discount type price lists */
if line_pricing or not new_order then
   update_accum_qty = yes.
else
   update_accum_qty = no.

/* PROMPT FOR CONFIGURATION IF NEW LINE */
/* For calico configured items the user is not to be prompted with*/
/* Std. bill as the user has built the configuration they will be */
/* Prompted if they wish to review bill.                          */
if (new qod_det or prev_qty_ord = 0)
or (cf_config and cf_rm_old_bom) then do:

   if qod_due_date <> ?
   then
      qod_qob_rev   = qod_due_date.
   else
      qod_qob_rev   = today.

   cpex_rev_date = qod_due_date.

   /* Get the cost from remote db if necessary */
   {gprun.i ""gpsct05x.p""
      "(qod_part, qod_site, 1,
        output glxcst, output curcst)" }
/*GUI*/ if global-beam-me-up then undo, leave.


   qod_std_cost = glxcst * qod_um_conv.

   if qod_qty_quot <> 0 then do:
      /* GA46 FOLLOWING 2 MESSAGE STATEMENTS CAUSE A PAUSE IF ANY
      MESSAGES ARE ON THE SCREEN ALREADY */
      message.
      message.

      if not cf_config then do:
         pause 0.
         qod_qob_std = yes.

         FORM /*GUI*/ 
            
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
qod_qob_std colon 17
            qod_qob_rev colon 17 label "Effective"
            cfg colon 17
            space(2)
          SKIP(.4)  /*GUI*/
with frame bom overlay attr-space side-labels row 9 column 25 NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-bom-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame bom = F-bom-title.
 RECT-FRAME-LABEL:HIDDEN in frame bom = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame bom =
  FRAME bom:HEIGHT-PIXELS - RECT-FRAME:Y in frame bom - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME bom = FRAME bom:WIDTH-CHARS - .5.  /*GUI*/


         /* SET EXTERNAL LABELS */
         setFrameLabels(frame bom:handle).

         if new qod_det then do:
            find ptp_det where ptp_part = qod_part
               and ptp_site = qod_site no-lock no-error.
            if available ptp_det then
            assign
               qod_cfg_type = ptp_cfg_type.
            else do:
               find pt_mstr where pt_part = qod_part no-lock no-error.
               if available pt_mstr then
               assign
                  qod_cfg_type = pt_cfg_type.
            end.
         end.

         assign
            cfg = qod_cfg_type
            cfglabel = ""
            cfgcode = "".

         /* GET MNEMONIC cfg AND cfglabel FROM LNGD_DET */
         {gplngn2a.i &file     = ""pt_mstr""
            &field    = ""pt_cfg_type""
            &code     = qod_cfg_type
            &mnemonic = cfg
            &label    = cfglabel}

         display
            qod_qob_std
            qod_qob_rev
            cfg
         with frame bom.

         set
            qod_qob_std
            qod_qob_rev
            cfg
         with frame bom.

         /* VALIDATE cfg MNEMONIC AGAINST LNGD_DET */
         if valid_lngd then do:
            {gplngv.i &file     = ""pt_mstr""
               &field    = ""pt_cfg_type""
               &mnemonic = cfg
               &isvalid  = valid_mnemonic}

            if not valid_mnemonic then do:
               /* INVALID CHARACTER */
               {pxmsg.i &MSGNUM=3093 &ERRORLEVEL=3}
               next-prompt cfg with frame bom.
               undo, retry.
            end.

            /* GET cfgcode & cfglabel FROM LNGD_DET */
            {gplnga2n.i &file     = ""pt_mstr""
               &field    = ""pt_cfg_type""
               &mnemonic = cfg
               &code     = cfgcode
               &label    = cfglabel}

         end.
         if valid_lngd and available lngd_det then
            assign qod_cfg_type = cfgcode.
         else qod_cfg_type = cfg.

         hide frame bom.
      end.

      else do:
         modify_sob = no.
         pause 0.
         display modify_sob qod_qob_rev with frame bom1.
         set modify_sob with frame bom1.
         hide frame bom1.
      end.

      cpex_rev_date = qod_qob_rev.

      /*CREATE SO BILL RECORDS*/
      if cf_config then
      assign
         cf_um = qod_um
         cf_um_conv = qod_um_conv.

      if new sod_det or prev_qty_ord = 0 or cf_rm_old_bom then
      {gprun.i ""sosomtf1.p""
         "(input qod_part,
           input """",
           input qod_qty_quot * qod_um_conv,
           input 0,
           input cpex_sod_part)"}
/*GUI*/ if global-beam-me-up then undo, leave.


      if cf_config and cf_error_bom then do:
         undo_all2 = true.
         leave.
      end.

      /* Calculate the price of the resulting configuration */
      {gprun.i ""sqpccala.p"" "(update_accum_qty, yes)"}
/*GUI*/ if global-beam-me-up then undo, leave.


      /* CHECK IF CONFIGURATION NEEDS REPRICING DUE "ACCUM QTY"
         CAPABILITY OF BEST PRICING */
      find first wrep_wkfl where wrep_line = qod_line and
         wrep_part = qod_part and
         wrep_parent          and
         wrep_rep
      no-lock no-error.

      if available wrep_wkfl then
         config_edited = yes. /*forces repricingw in recnfig*/

      if not cf_config then do:
         if qod_qob_std = no then do:
            /*EDIT SO BILL*/
            {gprun.i ""sosomtf2.p""
               "(input qod_part,
                 input """",
                 input qod_qty_quot * qod_um_conv,
                 input 0,
                 input cpex_sod_part)"}
/*GUI*/ if global-beam-me-up then undo, leave.

            config_edited = yes.
         end.
      end. /*not cf_config*/

      else do:
         if modify_sob then do:
            {gprun.i ""sosomtf2.p""
               "(input qod_part,
                 input """",
                 input qod_qty_quot * qod_um_conv,
                 input 0,
                 input cpex_sod_part)"}
/*GUI*/ if global-beam-me-up then undo, leave.

            config_edited = yes.
         end.
      end.

   end.

   if sngl_ln then
      display
/*hk-s-015         qod_std_cost*/
         qod_um_conv
      with frame d.

end.

/* REVIEW CONFIGURATION IF OLD CONFIGURED PART */
else do:

   if qod_qty_quot = 0 then do:
      /* The following code has been duplicated in cfsqrbom.p */
      /* Please review it when making changes here. */
      for each sob_det where
         sob_nbr  = "qod_det" + qod_nbr and
         sob_line = qod_line
      exclusive-lock:
/*GUI*/ if global-beam-me-up then undo, leave.


         /*UPDATE ACCUM QTY WORKFILES WITH REVERSAL*/
         if line_pricing or not new_order then do:
            /*Qualified the qty (sob_qty_req) and extended list   */
            /*(sob_qty_req * sob_tot_std) parameters to divide by */
            /*U/M conversion ratio since these include this factor*/
            /*Already.                                            */
            {gprun.i ""gppiqty2.p""
               "(qod_line,
                 sob_part,
                 - (sob_qty_req / qod_um_conv),
                 - (sob_qty_req * sob_tot_std / qod_um_conv),
                 qod_um,
                 no,
                 yes,
                 yes)"}
/*GUI*/ if global-beam-me-up then undo, leave.

         end.

         delete sob_det.

      end.
/*GUI*/ if global-beam-me-up then undo, leave.


      /* Get the cost from remote db if necessary */
      {gprun.i ""gpsct05x.p""
         "(pt_part, qod_site, 1,
           output glxcst, output curcst)" }
/*GUI*/ if global-beam-me-up then undo, leave.


      qod_std_cost = glxcst * qod_um_conv.

      /* DELETE ALL RELATED PRICE LIST HISTORY AND CURRENT  */
      /* PRICE LIST WORKFILE ENTRIES FOR THIS SALES ORDER   */
      /* BILL.  SET qod_list_pr TO THE VALUE OF THE PARENT  */
      /* LIST PRICE AND UPON RETURN TO THE CALLING PROCEDURE*/
      /* SUBSEQUENT PROCESSING WILL RESULT IN NO DISCOUNTS  */
      /* AND LIST AND NET PRICES WILL BE THE SAME.          */

      qod_list_pr = 0.

      for each pih_hist where pih_doc_type = 2
            and pih_nbr      = qod_nbr
            and pih_line     = qod_line
      exclusive-lock:
         if pih_amt_type = "1" and pih_option = "" then
            qod_list_pr = pih_amt.
         else
            delete pih_hist.
      end.

      for each wkpi_wkfl exclusive-lock:
         if wkpi_option = "" and wkpi_amt_type = "1" then
            qod_list_pr = wkpi_amt.
         else
            delete wkpi_wkfl.
      end.

      assign                      /*make sure nothing else happens*/
         exclude_confg_disc = no  /*upon returning to the calling */
         select_confg_disc  = no  /*procedure.                    */
         found_confg_disc   = no
         .

      qod_disc_pct = 0.
      qod_price = qod_list_pr.

      /* DETERMINE DISCOUNT DISPLAY FORMAT */
      {gppidisc.i pic_qo_fact qod_disc_pct pic_qo_rfact}

      display
         qod_list_pr
         discount    when (discount >= -9999.9999 and discount <=  9999.9999)
         qod_price
      with frame c.
   end.

   else do:
      if prev_qty_ord <> qod_qty_quot * qod_um_conv and
         prev_qty_ord <> 0
      then do:

         for each sob_det where
            sob_nbr = "qod_det" + qod_nbr and
            sob_line = qod_line
         exclusive-lock:
/*GUI*/ if global-beam-me-up then undo, leave.


            /* UPDATE ACCUM QTY WORKFILES WITH DIFFERENCE */
            prev_qty_req = sob_qty_req.

            sob_qty_req = sob_qty_req * qod_qty_quot *
                          qod_um_conv / prev_qty_ord.

            if line_pricing or not new_order then do:
               /* Qualified the qty (sob_qty_req) and extended list  */
               /* (sob_qty_req * sob_tot_std) parameters to divide by */
               /* U/M conversion ratio since these include this factor*/
               /* Already.                                            */
               {gprun.i ""gppiqty2.p""
                  "(qod_line,
                    sob_part,
                    (sob_qty_req - prev_qty_req) / qod_um_conv,
                    (sob_qty_req - prev_qty_req) * sob_tot_std / qod_um_conv,
                    qod_um,
                    no,
                    yes,
                    yes)"}
/*GUI*/ if global-beam-me-up then undo, leave.

            end.
         end.
/*GUI*/ if global-beam-me-up then undo, leave.


         config_edited = yes.

      end.

      find first sob_det where sob_nbr = "qod_det" + qod_nbr
         and sob_line = qod_line
      no-lock no-error.

      pause 0.

      modify_sob = no.

      assign
         cfg = qod_cfg_type
         cfglabel = ""
         cfgcode = "".

      /* GET MNEMONIC cfg AND cfglabel FROM LNGD_DET */
      {gplngn2a.i &file     = ""pt_mstr""
         &field    = ""pt_cfg_type""
         &code     = qod_cfg_type
         &mnemonic = cfg
         &label    = cfglabel}

      /* ALLOW FOR CONFIGURATION MODIFICATION ONLY IF REPRICING  */
      /* IS YES.  OTHERWISE IF A CONFIGURATION CHANGE OCCURS (ADD*/
      /* AN OPTION, DELETE AN OPTION, SETTING QTY TO 0, WILL     */
      /* REFLECT IN A CHANGE TO THE LINE ITEM LIST AND NET PRICE */
      /* WHICH WILL NOT BE REFLECTED IN PRICE LIST HISTORY.  IF  */
      /* PRICE LIST HISTORY IS NOT MAINTAINED, THEN WHEN POSTING */
      /* TO THE G/L, DISCOUNTS WILL BE OUT OF BALANCE.           */

      if reprice_dtl or new_order then do:
         display
            modify_sob
            qod_qob_rev
            cfg
         with frame bom1.

         set
            modify_sob
            cfg
         with frame bom1.

         /* VALIDATE CFG MNEMONIC AGAINST LNGD_DET */
         if valid_lngd then do:
            {gplngv.i &file     = ""pt_mstr""
               &field    = ""pt_cfg_type""
               &mnemonic = cfg
               &isvalid  = valid_mnemonic}

            if not valid_mnemonic then do:
               /* INVALID CHARACTER */
               {pxmsg.i &MSGNUM=3093 &ERRORLEVEL=3}
               next-prompt cfg with frame bom.
               undo, retry.
            end.

            /* GET cfgcode & cfglabel FROM LNGD_DET */
            {gplnga2n.i &file     = ""pt_mstr""
               &field    = ""pt_cfg_type""
               &mnemonic = cfg
               &code     = cfgcode
               &label    = cfglabel}

         end.

         if valid_lngd and available lngd_det then
            qod_cfg_type = cfgcode.
         else
            qod_cfg_type = cfg.

         hide frame bom1.
      end.

      if modify_sob then do:
         if sngl_ln then hide frame d.

         config_edited = yes.

         {gprun.i ""sosomtf2.p""
            "(input qod_part,
              input """",
              input qod_qty_quot * qod_um_conv,
              input 0,
              input cpex_sod_part)"}
/*GUI*/ if global-beam-me-up then undo, leave.


         if sngl_ln then view frame d.
      end.

      /*Reprice current configuration*/
      else if line_pricing or reprice_dtl then do:

         /* Get the cost from remote db if necessary */
         {gprun.i ""gpsct05x.p""
            "(pt_part, qod_site, 1,
              output glxcst, output curcst)" }
/*GUI*/ if global-beam-me-up then undo, leave.


         qod_std_cost = glxcst * qod_um_conv.
         {gprun.i ""sqpccala.p"" "(no, yes)"}
/*GUI*/ if global-beam-me-up then undo, leave.

      end.

   end.

end.

/* REPRICE COMPLETE CONFIGURATION */
if (line_pricing or reprice_dtl) and config_edited then do:
   {gprun.i ""sqqomtl2.p"" "(input qod_nbr, input qod_line)"}
/*GUI*/ if global-beam-me-up then undo, leave.


/*hk-s-015   if sngl_ln then
         display qod_std_cost with frame d.*/
end.

undo_all2 =  false. /* flag successful completion of this routine */
